/*     */ package com.zimbra.qa.unittest;
/*     */ 
/*     */ import com.google.common.collect.Maps;
/*     */ import com.zimbra.client.ZMailbox;
/*     */ import com.zimbra.common.auth.ZAuthToken;
/*     */ import com.zimbra.common.httpclient.HttpClientUtil;
/*     */ import com.zimbra.common.service.ServiceException;
/*     */ import com.zimbra.common.soap.Element;
/*     */ import com.zimbra.common.soap.SoapHttpTransport;
/*     */ import com.zimbra.common.soap.SoapProtocol;
/*     */ import com.zimbra.cs.account.Account;
/*     */ import com.zimbra.cs.account.AuthToken;
/*     */ import com.zimbra.cs.account.AuthTokenException;
/*     */ import com.zimbra.cs.account.Provisioning;
/*     */ import com.zimbra.cs.account.Server;
/*     */ import com.zimbra.cs.account.accesscontrol.AdminRight;
/*     */ import com.zimbra.cs.account.accesscontrol.Rights.Admin;
/*     */ import com.zimbra.cs.account.soap.SoapProvisioning;
/*     */ import com.zimbra.cs.service.AuthProvider;
/*     */ import com.zimbra.soap.JaxbUtil;
/*     */ import com.zimbra.soap.admin.message.AuthRequest;
/*     */ import com.zimbra.soap.admin.message.AuthResponse;
/*     */ import java.io.File;
/*     */ import java.io.FileInputStream;
/*     */ import java.io.IOException;
/*     */ import java.io.InputStream;
/*     */ import java.util.Map;
/*     */ import junit.framework.Assert;
/*     */ import org.apache.commons.httpclient.HttpClient;
/*     */ import org.apache.commons.httpclient.HttpException;
/*     */ import org.apache.commons.httpclient.HttpMethod;
/*     */ import org.apache.commons.httpclient.methods.GetMethod;
/*     */ import org.apache.commons.httpclient.methods.PostMethod;
/*     */ import org.junit.AfterClass;
/*     */ import org.junit.BeforeClass;
/*     */ import org.junit.Test;
/*     */ 
/*     */ public class TestServiceServlet
/*     */ {
/*  40 */   private static final String NAME_PREFIX = TestUserServlet.class.getSimpleName();
/*  41 */   private static final String USER_NAME = NAME_PREFIX + "user1";
/*     */   private static Account delegatedAdminWithRights;
/*     */   private static Account delegatedAdminWithoutRights;
/*  44 */   private static String DELEGATED_ADMIN_WITH_RIGHTS = "TestServiceServletDelegatedAdmin1";
/*  45 */   private static String DELEGATED_ADMIN_WITHOUT_RIGHTS = "TestServiceServletDelegatedAdmin2";
/*     */   private static Provisioning prov;
/*     */   private static Server localServer;
/*     */   private static String baseURL;
/*     */   
/*     */   @BeforeClass
/*  51 */   public static void before() throws Exception { cleanup();
/*  52 */     TestUtil.createAccount(USER_NAME);
/*  53 */     baseURL = TestUtil.getBaseUrl() + "/fromservice/";
/*  54 */     prov = Provisioning.getInstance();
/*  55 */     localServer = prov.getLocalServer();
/*  56 */     Map<String, Object> attrs = Maps.newHashMap();
/*  57 */     attrs.put("zimbraIsDelegatedAdminAccount", "TRUE");
/*  58 */     attrs.put("zimbraAdminConsoleUIComponents", "accountListView");
/*  59 */     attrs.put("zimbraAdminConsoleUIComponents", "downloadsView");
/*  60 */     attrs.put("zimbraAdminConsoleUIComponents", "DLListView");
/*  61 */     delegatedAdminWithoutRights = TestUtil.createAccount(TestUtil.addDomainIfNecessary(DELEGATED_ADMIN_WITHOUT_RIGHTS), attrs);
/*     */     
/*  63 */     attrs = Maps.newHashMap();
/*  64 */     attrs.put("zimbraIsDelegatedAdminAccount", "TRUE");
/*  65 */     attrs.put("zimbraAdminConsoleUIComponents", "accountListView");
/*  66 */     attrs.put("zimbraAdminConsoleUIComponents", "downloadsView");
/*  67 */     attrs.put("zimbraAdminConsoleUIComponents", "DLListView");
/*  68 */     delegatedAdminWithRights = TestUtil.createAccount(TestUtil.addDomainIfNecessary(DELEGATED_ADMIN_WITH_RIGHTS), attrs);
/*     */     
/*  70 */     SoapProvisioning adminSoapProv = TestUtil.newSoapProvisioning();
/*  71 */     TestUtil.grantRightToAdmin(adminSoapProv, com.zimbra.soap.type.TargetType.fromString(com.zimbra.cs.account.accesscontrol.TargetType.server.toString()), localServer.getName(), delegatedAdminWithRights.getName(), Rights.Admin.R_deployZimlet.getName());
/*     */     
/*     */ 
/*  74 */     TestUtil.grantRightToAdmin(adminSoapProv, com.zimbra.soap.type.TargetType.fromString(com.zimbra.cs.account.accesscontrol.TargetType.server.toString()), localServer.getName(), delegatedAdminWithRights.getName(), Rights.Admin.R_flushCache.getName());
/*     */     
/*     */ 
/*     */ 
/*  78 */     GetMethod method = new GetMethod(String.format("%sflushacl", new Object[] { baseURL }));
/*  79 */     addAuthTokenHeader(method, AuthProvider.getAdminAuthToken().getEncoded());
/*  80 */     HttpClient client = new HttpClient();
/*  81 */     int code = HttpClientUtil.executeMethod(client, method);
/*  82 */     if (200 != code) {
/*  83 */       Assert.fail(String.format("Failed to flush all cache in /zimbra web app. Response code: %d", new Object[] { Integer.valueOf(code) }));
/*     */     }
/*     */   }
/*     */   
/*     */   private static void cleanup() throws Exception {
/*  88 */     if (TestUtil.accountExists(USER_NAME)) {
/*  89 */       TestUtil.deleteAccount(USER_NAME);
/*     */     }
/*  91 */     if (TestUtil.accountExists(DELEGATED_ADMIN_WITH_RIGHTS)) {
/*  92 */       TestUtil.deleteAccount(DELEGATED_ADMIN_WITH_RIGHTS);
/*     */     }
/*  94 */     if (TestUtil.accountExists(DELEGATED_ADMIN_WITHOUT_RIGHTS)) {
/*  95 */       TestUtil.deleteAccount(DELEGATED_ADMIN_WITHOUT_RIGHTS);
/*     */     }
/*     */   }
/*     */   
/*     */   @AfterClass
/*     */   public static void tearDown() throws Exception
/*     */   {}
/*     */   
/*     */   private static void addAuthTokenHeader(HttpMethod method, String token)
/*     */   {
/* 105 */     method.addRequestHeader("authtoken", token);
/*     */   }
/*     */   
/*     */   private String getAdminAuthToken(String adminName) throws ServiceException, IOException {
/* 109 */     SoapHttpTransport transport = new SoapHttpTransport(TestUtil.getAdminSoapUrl());
/* 110 */     AuthRequest authReq = new AuthRequest(adminName, "test123");
/*     */     
/* 112 */     authReq.setCsrfSupported(Boolean.valueOf(false));
/* 113 */     Element response = transport.invoke(JaxbUtil.jaxbToElement(authReq, SoapProtocol.SoapJS.getFactory()));
/* 114 */     AuthResponse authResp = (AuthResponse)JaxbUtil.elementToJaxb(response);
/* 115 */     return authResp.getAuthToken();
/*     */   }
/*     */   
/*     */   private void verifyAdminGET(String url) throws ServiceException, AuthTokenException, HttpException, IOException {
/* 119 */     HttpClient client = new HttpClient();
/* 120 */     ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
/* 121 */     GetMethod method = new GetMethod(url);
/* 122 */     int respCode = HttpClientUtil.executeMethod(client, method);
/* 123 */     Assert.assertEquals("Should be getting error code without an auth token", 401, respCode);
/*     */     
/* 125 */     method = new GetMethod(url);
/* 126 */     addAuthTokenHeader(method, mbox.getAuthToken().getValue());
/* 127 */     respCode = HttpClientUtil.executeMethod(client, method);
/* 128 */     Assert.assertEquals("Should be getting error code with user's auth token", 401, respCode);
/*     */     
/* 130 */     method = new GetMethod(url);
/* 131 */     addAuthTokenHeader(method, AuthProvider.getAdminAuthToken().getEncoded());
/* 132 */     respCode = HttpClientUtil.executeMethod(client, method);
/* 133 */     Assert.assertEquals("Should be getting code 200 with super admin's auth token", 200, respCode);
/*     */     
/* 135 */     method = new GetMethod(url);
/* 136 */     addAuthTokenHeader(method, getAdminAuthToken(delegatedAdminWithRights.getName()));
/* 137 */     respCode = HttpClientUtil.executeMethod(client, method);
/* 138 */     Assert.assertEquals("Should be getting code 200 with permitted delegated admin's auth token", 200, respCode);
/*     */     
/* 140 */     method = new GetMethod(url);
/* 141 */     addAuthTokenHeader(method, getAdminAuthToken(delegatedAdminWithoutRights.getName()));
/* 142 */     respCode = HttpClientUtil.executeMethod(client, method);
/* 143 */     Assert.assertEquals("Should be getting code 401 with unpermitted delegated admin's auth token", 401, respCode);
/*     */   }
/*     */   
/*     */   private void verifyNonAdminGET(String url) throws ServiceException, AuthTokenException, HttpException, IOException {
/* 147 */     HttpClient client = new HttpClient();
/* 148 */     ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
/* 149 */     GetMethod method = new GetMethod(url);
/* 150 */     int respCode = HttpClientUtil.executeMethod(client, method);
/* 151 */     Assert.assertEquals("Should be getting error code without an auth token", 401, respCode);
/*     */     
/* 153 */     method = new GetMethod(url);
/* 154 */     addAuthTokenHeader(method, mbox.getAuthToken().getValue());
/* 155 */     respCode = HttpClientUtil.executeMethod(client, method);
/* 156 */     Assert.assertEquals("Should be getting code 200 with user's auth token", 200, respCode);
/*     */     
/* 158 */     method = new GetMethod(url);
/* 159 */     addAuthTokenHeader(method, AuthProvider.getAdminAuthToken().getEncoded());
/* 160 */     respCode = HttpClientUtil.executeMethod(client, method);
/* 161 */     Assert.assertEquals("Should be getting code 200 with super admin's auth token", 200, respCode);
/*     */     
/* 163 */     method = new GetMethod(url);
/* 164 */     addAuthTokenHeader(method, getAdminAuthToken(delegatedAdminWithRights.getName()));
/* 165 */     respCode = HttpClientUtil.executeMethod(client, method);
/* 166 */     Assert.assertEquals("Should be getting code 200 with permitted delegated admin's auth token", 200, respCode);
/*     */     
/* 168 */     method = new GetMethod(url);
/* 169 */     addAuthTokenHeader(method, getAdminAuthToken(delegatedAdminWithoutRights.getName()));
/* 170 */     respCode = HttpClientUtil.executeMethod(client, method);
/* 171 */     Assert.assertEquals("Should be getting code 200 with unpermitted delegated admin's auth token", 200, respCode);
/*     */   }
/*     */   
/*     */   private void deployAdminVersionCheck() throws AuthTokenException, ServiceException, HttpException, IOException {
/* 175 */     HttpClient client = new HttpClient();
/* 176 */     String url = baseURL + "deployzimlet";
/* 177 */     PostMethod method = new PostMethod(url);
/* 178 */     addAuthTokenHeader(method, AuthProvider.getAdminAuthToken().getEncoded());
/* 179 */     method.addRequestHeader("Zimlet", "com_zimbra_adminversioncheck");
/* 180 */     File zimletFile = new File("/opt/zimbra/zimlets/com_zimbra_adminversioncheck.zip");
/* 181 */     if (zimletFile.exists()) {
/* 182 */       InputStream targetStream = new FileInputStream(zimletFile);
/* 183 */       method.setRequestBody(targetStream);
/*     */     }
/* 185 */     int respCode = HttpClientUtil.executeMethod(client, method);
/* 186 */     Assert.assertEquals("Super admin should be able to deploy com_zimbra_adminversioncheck admin extension", 200, respCode);
/*     */   }
/*     */   
/*     */   @Test
/*     */   public void testFlushZimlets() throws Exception {
/* 191 */     String url = baseURL + "flushzimlets";
/* 192 */     verifyAdminGET(url);
/*     */   }
/*     */   
/*     */   @Test
/*     */   public void testFlushSkins() throws Exception {
/* 197 */     String url = baseURL + "flushskins";
/* 198 */     verifyAdminGET(url);
/*     */   }
/*     */   
/*     */   @Test
/*     */   public void testFlushStrings() throws Exception {
/* 203 */     String url = baseURL + "flushuistrings";
/* 204 */     verifyAdminGET(url);
/*     */   }
/*     */   
/*     */   @Test
/*     */   public void testLoadSkins() throws Exception {
/* 209 */     String url = baseURL + "loadskins";
/* 210 */     verifyNonAdminGET(url);
/*     */   }
/*     */   
/*     */   @Test
/*     */   public void testLoadLocales() throws Exception {
/* 215 */     String url = baseURL + "loadlocales";
/* 216 */     verifyNonAdminGET(url);
/*     */   }
/*     */   
/*     */   @Test
/*     */   public void testDeployZimlet() throws Exception {
/* 221 */     ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
/* 222 */     HttpClient client = new HttpClient();
/* 223 */     String url = baseURL + "deployzimlet";
/* 224 */     PostMethod method = new PostMethod(url);
/* 225 */     addAuthTokenHeader(method, mbox.getAuthToken().getValue());
/* 226 */     method.addRequestHeader("Zimlet", "com_zimbra_phone");
/* 227 */     File zimletFile = new File("/opt/zimbra/zimlets/com_zimbra_phone.zip");
/* 228 */     if (zimletFile.exists()) {
/* 229 */       InputStream targetStream = new FileInputStream(zimletFile);
/* 230 */       method.setRequestBody(targetStream);
/*     */     }
/* 232 */     int respCode = HttpClientUtil.executeMethod(client, method);
/* 233 */     Assert.assertEquals("Should be getting error code with user's auth token", 401, respCode);
/*     */     
/* 235 */     method = new PostMethod(url);
/* 236 */     addAuthTokenHeader(method, AuthProvider.getAdminAuthToken().getEncoded());
/* 237 */     method.addRequestHeader("Zimlet", "com_zimbra_phone");
/* 238 */     if (zimletFile.exists()) {
/* 239 */       InputStream targetStream = new FileInputStream(zimletFile);
/* 240 */       method.setRequestBody(targetStream);
/*     */     }
/* 242 */     respCode = HttpClientUtil.executeMethod(client, method);
/* 243 */     Assert.assertEquals("Should be getting code 200 with super admin's auth token", 200, respCode);
/*     */     
/* 245 */     method = new PostMethod(url);
/* 246 */     addAuthTokenHeader(method, getAdminAuthToken(delegatedAdminWithRights.getName()));
/* 247 */     method.addRequestHeader("Zimlet", "com_zimbra_phone");
/* 248 */     if (zimletFile.exists()) {
/* 249 */       InputStream targetStream = new FileInputStream(zimletFile);
/* 250 */       method.setRequestBody(targetStream);
/*     */     }
/* 252 */     respCode = HttpClientUtil.executeMethod(client, method);
/* 253 */     Assert.assertEquals("Should be getting code 200 with permitted delegated admin's auth token", 200, respCode);
/*     */     
/* 255 */     method = new PostMethod(url);
/* 256 */     addAuthTokenHeader(method, getAdminAuthToken(delegatedAdminWithoutRights.getName()));
/* 257 */     method.addRequestHeader("Zimlet", "com_zimbra_phone");
/* 258 */     if (zimletFile.exists()) {
/* 259 */       InputStream targetStream = new FileInputStream(zimletFile);
/* 260 */       method.setRequestBody(targetStream);
/*     */     }
/* 262 */     respCode = HttpClientUtil.executeMethod(client, method);
/* 263 */     Assert.assertEquals("Should be getting code 401 with unpermitted delegated admin's auth token", 401, respCode);
/*     */   }
/*     */   
/*     */   @Test
/*     */   public void testDeployBadZimletName() throws Exception {
/* 268 */     ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
/* 269 */     HttpClient client = new HttpClient();
/* 270 */     String url = baseURL + "deployzimlet";
/* 271 */     PostMethod method = new PostMethod(url);
/* 272 */     addAuthTokenHeader(method, mbox.getAuthToken().getValue());
/* 273 */     method.addRequestHeader("Zimlet", "../conf/nginx.key");
/* 274 */     File zimletFile = new File("/opt/zimbra/zimlets/com_zimbra_phone.zip");
/* 275 */     if (zimletFile.exists()) {
/* 276 */       InputStream targetStream = new FileInputStream(zimletFile);
/* 277 */       method.setRequestBody(targetStream);
/*     */     }
/* 279 */     int respCode = HttpClientUtil.executeMethod(client, method);
/* 280 */     Assert.assertEquals("Should be getting error code with user's auth token", 401, respCode);
/*     */     
/* 282 */     method = new PostMethod(url);
/* 283 */     addAuthTokenHeader(method, AuthProvider.getAdminAuthToken().getEncoded());
/* 284 */     method.addRequestHeader("Zimlet", "../conf/nginx.key");
/* 285 */     if (zimletFile.exists()) {
/* 286 */       InputStream targetStream = new FileInputStream(zimletFile);
/* 287 */       method.setRequestBody(targetStream);
/*     */     }
/* 289 */     respCode = HttpClientUtil.executeMethod(client, method);
/* 290 */     Assert.assertEquals("Should be getting code 400 with super admin's auth token w/o upload", 400, respCode);
/*     */   }
/*     */   
/*     */   @Test
/*     */   public void testUnDeployZimlet() throws Exception {
/* 295 */     ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
/* 296 */     HttpClient client = new HttpClient();
/* 297 */     String url = baseURL + "undeployzimlet";
/* 298 */     PostMethod method = new PostMethod(url);
/* 299 */     addAuthTokenHeader(method, mbox.getAuthToken().getValue());
/* 300 */     method.addRequestHeader("Zimlet", "com_zimbra_archive");
/* 301 */     int respCode = HttpClientUtil.executeMethod(client, method);
/* 302 */     Assert.assertEquals("Should be getting error code with user's auth token", 401, respCode);
/*     */     
/* 304 */     method = new PostMethod(url);
/* 305 */     addAuthTokenHeader(method, AuthProvider.getAdminAuthToken().getEncoded());
/* 306 */     method.addRequestHeader("Zimlet", "com_zimbra_phone");
/* 307 */     respCode = HttpClientUtil.executeMethod(client, method);
/* 308 */     Assert.assertEquals("Should be getting code 200 with super admin's auth token", 200, respCode);
/*     */     
/* 310 */     method = new PostMethod(url);
/* 311 */     addAuthTokenHeader(method, getAdminAuthToken(delegatedAdminWithRights.getName()));
/* 312 */     method.addRequestHeader("Zimlet", "com_zimbra_phone");
/* 313 */     respCode = HttpClientUtil.executeMethod(client, method);
/* 314 */     Assert.assertEquals("Should be getting code 200 with permitted delegated admin's auth token", 200, respCode);
/*     */     
/* 316 */     method = new PostMethod(url);
/* 317 */     addAuthTokenHeader(method, getAdminAuthToken(delegatedAdminWithoutRights.getName()));
/* 318 */     method.addRequestHeader("Zimlet", "com_zimbra_phone");
/* 319 */     respCode = HttpClientUtil.executeMethod(client, method);
/* 320 */     Assert.assertEquals("Should be getting code 401 with unpermitted delegated admin's auth token", 401, respCode);
/*     */   }
/*     */   
/*     */   @Test
/*     */   public void testUnDeployBadZimletname() throws Exception {
/* 325 */     ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
/* 326 */     HttpClient client = new HttpClient();
/* 327 */     String url = baseURL + "undeployzimlet";
/* 328 */     PostMethod method = new PostMethod(url);
/* 329 */     addAuthTokenHeader(method, mbox.getAuthToken().getValue());
/* 330 */     method.addRequestHeader("Zimlet", "../conf/nginx.key");
/* 331 */     int respCode = HttpClientUtil.executeMethod(client, method);
/* 332 */     Assert.assertEquals("Should be getting error code with user's auth token", 401, respCode);
/*     */     
/* 334 */     method = new PostMethod(url);
/* 335 */     addAuthTokenHeader(method, AuthProvider.getAdminAuthToken().getEncoded());
/* 336 */     method.addRequestHeader("Zimlet", "../conf/nginx.key");
/* 337 */     respCode = HttpClientUtil.executeMethod(client, method);
/* 338 */     Assert.assertEquals("Should be getting code 400 with super admin's auth token", 400, respCode);
/*     */   }
/*     */   
/*     */   @Test
/*     */   public void testDeployAdminExtension() throws Exception {
/* 343 */     deployAdminVersionCheck();
/*     */     
/* 345 */     ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
/* 346 */     HttpClient client = new HttpClient();
/* 347 */     String url = baseURL + "deployzimlet";
/* 348 */     PostMethod method = new PostMethod(url);
/* 349 */     addAuthTokenHeader(method, mbox.getAuthToken().getValue());
/* 350 */     method.addRequestHeader("Zimlet", "com_zimbra_phone");
/* 351 */     File zimletFile = new File("/opt/zimbra/zimlets/com_zimbra_adminversioncheck.zip");
/* 352 */     if (zimletFile.exists()) {
/* 353 */       InputStream targetStream = new FileInputStream(zimletFile);
/* 354 */       method.setRequestBody(targetStream);
/*     */     }
/* 356 */     int respCode = HttpClientUtil.executeMethod(client, method);
/* 357 */     Assert.assertEquals("Should be getting error code with user's auth token", 401, respCode);
/*     */     
/* 359 */     method = new PostMethod(url);
/* 360 */     addAuthTokenHeader(method, getAdminAuthToken(delegatedAdminWithRights.getName()));
/* 361 */     method.addRequestHeader("Zimlet", "com_zimbra_adminversioncheck");
/* 362 */     if (zimletFile.exists()) {
/* 363 */       InputStream targetStream = new FileInputStream(zimletFile);
/* 364 */       method.setRequestBody(targetStream);
/*     */     }
/* 366 */     respCode = HttpClientUtil.executeMethod(client, method);
/* 367 */     Assert.assertEquals("Should be getting code 401 with permitted delegated admin's auth token", 401, respCode);
/*     */     
/* 369 */     method = new PostMethod(url);
/* 370 */     addAuthTokenHeader(method, getAdminAuthToken(delegatedAdminWithoutRights.getName()));
/* 371 */     method.addRequestHeader("Zimlet", "com_zimbra_adminversioncheck");
/* 372 */     if (zimletFile.exists()) {
/* 373 */       InputStream targetStream = new FileInputStream(zimletFile);
/* 374 */       method.setRequestBody(targetStream);
/*     */     }
/* 376 */     respCode = HttpClientUtil.executeMethod(client, method);
/* 377 */     Assert.assertEquals("Should be getting code 401 with unpermitted delegated admin's auth token", 401, respCode);
/*     */   }
/*     */   
/*     */   @Test
/*     */   public void testUnDeployAdminExtension() throws Exception {
/* 382 */     deployAdminVersionCheck();
/*     */     
/* 384 */     ZMailbox mbox = TestUtil.getZMailbox(USER_NAME);
/* 385 */     HttpClient client = new HttpClient();
/* 386 */     String url = baseURL + "undeployzimlet";
/* 387 */     PostMethod method = new PostMethod(url);
/* 388 */     addAuthTokenHeader(method, mbox.getAuthToken().getValue());
/* 389 */     method.addRequestHeader("Zimlet", "com_zimbra_adminversioncheck");
/* 390 */     int respCode = HttpClientUtil.executeMethod(client, method);
/* 391 */     Assert.assertEquals("Should be getting error code with user's auth token", 401, respCode);
/*     */     
/* 393 */     method = new PostMethod(url);
/* 394 */     addAuthTokenHeader(method, getAdminAuthToken(delegatedAdminWithRights.getName()));
/* 395 */     method.addRequestHeader("Zimlet", "com_zimbra_adminversioncheck");
/* 396 */     respCode = HttpClientUtil.executeMethod(client, method);
/* 397 */     Assert.assertEquals("Delegated admin should not be allowed to undeploy admin extensions even with deployZimlet right", 401, respCode);
/*     */     
/* 399 */     method = new PostMethod(url);
/* 400 */     addAuthTokenHeader(method, getAdminAuthToken(delegatedAdminWithoutRights.getName()));
/* 401 */     method.addRequestHeader("Zimlet", "com_zimbra_adminversioncheck");
/* 402 */     respCode = HttpClientUtil.executeMethod(client, method);
/* 403 */     Assert.assertEquals("Delegated admin should not be allowed to undeploy admin extensions with or without deployZimlet right", 401, respCode);
/*     */     
/* 405 */     method = new PostMethod(url);
/* 406 */     addAuthTokenHeader(method, AuthProvider.getAdminAuthToken().getEncoded());
/* 407 */     method.addRequestHeader("Zimlet", "com_zimbra_adminversioncheck");
/* 408 */     respCode = HttpClientUtil.executeMethod(client, method);
/* 409 */     Assert.assertEquals("Super admin should be able to undeploy com_zimbra_adminversioncheck admin extension", 200, respCode);
/*     */   }
/*     */ }


/* Location:              /home/mint/zimbrastore.jar!/com/zimbra/qa/unittest/TestServiceServlet.class
 * Java compiler version: 7 (51.0)
 * JD-Core Version:       0.7.1
 */